package com.lianzhihui.romeex.ui.orepool;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.lianzhihui.romeex.MyApplication;
import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.adapter.RuleActivityAdapter;
import com.lianzhihui.romeex.config.AppConstants;
import com.lianzhihui.romeex.ui.base.BaseActivity;
import com.lianzhihui.romeex.utils.StatusBarUtil;
import com.lianzhihui.romeex.widget.ZFEmptyRecyclerView;

import java.text.MessageFormat;
import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @ProjectName: romeex
 * @Package: com.lianzhihui.romeex.ui.orepool
 * @ClassName: MyTeamActivity
 * @Description: java类作用描述
 * @Author: zhanghong
 * @CreateDate: 2020/11/24 15:02
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/11/24 15:02
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class CommunityRuleActivity extends BaseActivity {

    ArrayList<RuleBean> ruleBeans;
    @BindView(R.id.status_bar_id)
    View statusBarId;
    @BindView(R.id.include_top_iv_back)
    ImageView includeTopIvBack;
    @BindView(R.id.include_top_lin_newback)
    LinearLayout includeTopLinNewback;
    @BindView(R.id.include_top_tv_title)
    TextView includeTopTvTitle;
    @BindView(R.id.include_top_iv_right_second)
    ImageView includeTopIvRightSecond;
    @BindView(R.id.include_top_tv_right)
    TextView includeTopTvRight;
    @BindView(R.id.tv_user_level)
    TextView tv_user_level;
    @BindView(R.id.include_top_lin_right)
    LinearLayout includeTopLinRight;
    @BindView(R.id.include_top_lin_background)
    LinearLayout includeTopLinBackground;
    @BindView(R.id.app_top_bar)
    LinearLayout appTopBar;
    @BindView(R.id.myRecyclerView)
    ZFEmptyRecyclerView myRecyclerView;
    private RuleActivityAdapter ruleActivityAdapter;
    private int currentLevel = -1;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_community_rule_team;

    }

    @Override
    public boolean setFitSystemWindowFlag() {
        return false;
    }

    @Override
    protected void initView() {
        setTitleLayout();
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            currentLevel = extras.getInt(AppConstants.USERLEVEL, -1);
            if (currentLevel > 0) {
                tv_user_level.setText(MessageFormat.format("R{0}", currentLevel));
            }
        }
    }

    @Override
    protected void initData() {
        ruleActivityAdapter = new RuleActivityAdapter(this, new ArrayList<>(), 1);
        myRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        myRecyclerView.setAdapter(ruleActivityAdapter);
        ruleBeans = new ArrayList<>();
        ruleBeans.add(new RuleBean(1, "大小区业绩均达到100000XUSD", "伞下全网算力 5%", currentLevel == 1 ? true : false));
        ruleBeans.add(new RuleBean(2, "两条线，每条线各一个R1", "伞下全网算力 10%", currentLevel == 2 ? true : false));
        ruleBeans.add(new RuleBean(3, "两条线，每条线各一个R2", "伞下全网算力 15%", currentLevel == 3 ? true : false));
        ruleBeans.add(new RuleBean(4, "三条线，每条线各一个R3", "伞下全网算力 20%", currentLevel == 4 ? true : false));
        ruleBeans.add(new RuleBean(5, "三条线，每条线各一个R4", "伞下全网算力 25%", currentLevel == 5 ? true : false));
        myRecyclerView.showEmptyView(ruleBeans.size(), 1);
        ruleActivityAdapter.setNewData(ruleBeans);
    }

    @OnClick({})
    public void onClick(View view) {


    }


    private void setTitleLayout() {
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, statusBarId.getHeight());
        layoutParams.topMargin = StatusBarUtil.getStatusBarHeight(MyApplication.mContext);
        statusBarId.setLayoutParams(layoutParams);
        includeTopTvTitle.setText(getResources().getText(R.string.text_my_community_rule));
        includeTopLinBackground.setBackgroundColor(getResources().getColor(R.color.transparent));
    }


    public static class RuleBean {
        private int level;
        private String condition;
        private String earnings;
        private boolean ischeck;

        public RuleBean(int level, String condition, String earnings, boolean ischeck) {
            this.level = level;
            this.condition = condition;
            this.earnings = earnings;
            this.ischeck = ischeck;
        }

        public int getLevel() {
            return level;
        }

        public void setLevel(int level) {
            this.level = level;
        }

        public String getCondition() {
            return condition;
        }

        public void setCondition(String condition) {
            this.condition = condition;
        }

        public String getEarnings() {
            return earnings;
        }

        public void setEarnings(String earnings) {
            this.earnings = earnings;
        }

        public boolean isIscheck() {
            return ischeck;
        }

        public void setIscheck(boolean ischeck) {
            this.ischeck = ischeck;
        }
    }


}
